package model;
import Thread.*;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class FileTreatment {
	public List<algo> MoC;
    
    public FileTreatment() {
    	MoC = new ArrayList<algo>();
    }
    
    /** @throws IOException */
    public String read(String path) throws IOException 
    {
		BufferedReader lecture;
		String temp = "";
		
		lecture = new BufferedReader(new FileReader(path));
		
		lecture.readLine(); 
		
		while(lecture.ready() == true) temp = temp + "\n" + lecture.readLine(); 
		lecture.close();
		
		return temp;
    } 
    
    public void loader(String csv)
    {
        Scanner s = new Scanner(csv);
		s.useDelimiter(";|\n");
		while(s.hasNextLine()) {
			MoC.add(new algo(s.next(), Double.parseDouble(s.next()), Double.parseDouble(s.next()),
					Double.parseDouble(s.next()), Double.parseDouble(s.next()), Double.parseDouble(s.next()),
					Double.parseDouble(s.next()), Integer.parseInt(s.next()), Integer.parseInt(s.next())));
		}
		s.close();
    }

    public List<algo> data()
    {
        return MoC;
    }
}
